package com.example.goodsprovider.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.myshop.b2b.commonmodule.Userorder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
* @author likaiping
* @description 针对表【userorder】的数据库操作Mapper
* @createDate 2024-07-03 15:07:29
* @Entity com.myshop.b2b.commonmodule.Userorder
*/
public interface UserorderMapper extends BaseMapper<Userorder> {
    /**
     * 查询所有订单
     * @param uid
     * @return
     */
    @Select("select * from userorder WHERE uid = #{uid}")
    List<Userorder> getAllorder(@Param("uid")int uid);

    /**
     * 插入秒杀的订单，有n个用户id
     * @param goodsname
     * @param number
     * @param price
     * @param userIds
     * @return
     */
    @Insert("<script>" +
            "INSERT INTO userorder (goodsname, number, price,time,uid ) VALUES " +
            "<foreach collection='userIds' item='userId' separator=','>" +
            "   (#{goodsname}, #{number}, #{price},now(),#{userId})" +
            "</foreach>" +
            "</script>")
    boolean insertSecKillOrder(@Param("goodsname") String goodsname,
                               @Param("number")int number,
                               @Param("price")int price,
                               @Param("userIds") List<Integer> userIds);
}




